package com.boboPlanet.user.mq.peoducerBean;

import com.boboPlanet.user.mq.PlanetMiddleMqEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO 同步 ES文章数据bean
 * @Author: mis_wu
 * @Date: 2023/6/24
 * @Company planet
 **/
@Configuration
public class SyncEsArtDataMqConfig {

    @Bean
    public Queue syncEsQueue(){
        return new Queue(PlanetMiddleMqEnum.ES_INSERT_ARTICLE.getQueue(),true);
    }

    @Bean
    TopicExchange syncEsExchange() {
        return new TopicExchange(PlanetMiddleMqEnum.ES_INSERT_ARTICLE.getExchange(),true,false);
    }

    /**
     * todo:路由绑定交换机(routing-key)
     * @return Binding
     */
    @Bean
    Binding syncEsRouting() {
        return BindingBuilder.bind(this.syncEsQueue())
                .to(this.syncEsExchange())
                .with(PlanetMiddleMqEnum.ES_INSERT_ARTICLE.getRoutingKey());
    }
}
